package patracuolla.id.projects;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

//This is to write to the database which will later be compared to

public class FileMaker {
	public void makeDatabase(String path) throws IOException{
		
		//FileWriter fw = new FileWriter(path);
		//BufferedWriter bw = new BufferedWriter(fw);
		ScanFiles sf = new ScanFiles();
		long size = sf.getSize(path);
		String sequence = Long.toString(size);
		ReadDatabase rd = new ReadDatabase();
		File dir = new File("C:\\Users\\Student\\Documents\\Virus_Sandbox");
		String[] children = dir.list();
		if (children == null) {
		    // Either dir does not exist or is not a directory
		} else {
		    for (int i=0; i<children.length; i++) {
		        // Get filename of file or directory
		        String filename = children[i];
		        File file = new File(path);
				long filesize = file.length();
		        System.out.println(filename + ", " + filesize);
		    }
		}

		// The list of files can also be retrieved as File objects
		File[] files = dir.listFiles();

		// This filter only returns directories
		FileFilter fileFilter = new FileFilter() {
		    public boolean accept(File file) {
		        return file.isDirectory();
		    }
		};
		files = dir.listFiles(fileFilter);
		
		
		/*String myArray[] = {"one" , "two" , "three"};
		String writableString = "";
		
		for (String item : myArray){
			writableString += item + ", ";
		} 
		
	
		writableString = writableString.substring(0, writableString.length() - 2);
		System.out.println(writableString + sequence);
		*/
		//bw.write(sequence);
	//	bw.close();
	}
}
	
	//This reads the size of a file
	//METHOD SYNTAX--> scope + returntype + varname (Parameters)

